<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>标签管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/x-admin/font.css">
    <link rel="stylesheet" href="/static/css/x-admin/xadmin.css">
    <link rel="stylesheet" href="/static/css/admin-index.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>控制台</a>
        <a>文章管理</a>
        <a><cite>标签管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-sm layui-btn-radius" style="line-height:1.6em;margin-top:4px;float:right"
       href="javascript:location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-anim layui-anim-scale x-body">
    <div>
        <a href="/admin/cate/detail?cateType=newCate" class="layui-btn">新建标签</a>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>路径</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <#list tags as tag>
        <tr>
            <td>${tag.getTagId()}</td>
            <td>${tag.getTagName()}</td>
            <td>${tag.getTagPath()}</td>
            <td>
                <button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del(this, ${tag.getTagId()})">
                    删除
                </button>
                <button class="layui-btn layui-btn-xs" onclick="update(${tag.getTagId()})">修改</button>
            </td>
        </tr>
        </#list>
        </tbody>
    </table>
    <!-- 分页 -->
    <div class="layui-box layui-laypage layui-laypage-default">
        <#if !pageInfo.isFirstPage>
                <a href="/admin/tags/showAllTags?pageNum=${pageInfo.firstPage}&pageSize=${pageInfo.pageSize}"
                   class="layui-laypage-next">首页</a>
        <#elseif pageInfo.isFirstPage>
            <a class="layui-laypage-next layui-disabled">首页</a>
        </#if>
        <#if pageInfo.hasPreviousPage>
            <a href="/admin/tags/showAllTags?pageNum=${pageInfo.prePage}&pageSize=${pageInfo.pageSize}"
               class="layui-laypage-prev ">上一页</a>
        <#elseif !pageInfo.hasPreviousPage>
            <a class="layui-laypage-prev layui-disabled">上一页</a>
        </#if>

         <#list pageInfo.navigatepageNums as nav>
             <#if nav == pageInfo.pageNum>
                 <span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>${nav}</em></span>
             </#if>
             <#if nav != pageInfo.pageNum>
                 <a href="/admin/tags/showAllTags?pageNum=${nav}&pageSize=${pageInfo.pageSize}">${nav}</a>
             </#if>
         </#list>
        <#if pageInfo.hasNextPage>
            <a href="/admin/tags/showAllTags?pageNum=${pageInfo.nextPage}&pageSize=${pageInfo.pageSize}"
               class="layui-laypage-next">下一页</a>
        </#if>
        <#if !pageInfo.hasNextPage>
            <a class="layui-laypage-next layui-disabled">下一页</a>
        </#if>
        <#if !pageInfo.isLastPage>
            <a href="/admin/tags/showAllTags?pageNum=${pageInfo.lastPage}&pageSize=${pageInfo.pageSize}"
               class="layui-laypage-next">尾页</a>
        </#if>
        <#if pageInfo.isLastPage>
            <a class="layui-laypage-next layui-disabled">尾页</a>
        </#if>
    </div>
</div>
<script type="text/javascript" src="/static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/js/x-admin/xadmin.js"></script>
<script type="text/javascript">
    /*删除*/
    function del(obj, id) {
        layer.confirm('确认要删除吗？', {
            icon: 3,
            anim: 2
        }, function () {
            $.ajax({
                url: "/admin/tags/deleteTag",
                data: {
                    tagId: id
                },
                type: "post",
                success: function (data) {
                    if (data.code === 2010) {
                        $(obj).parents("tr").remove();
                        layer.msg(data.message, {
                            icon: 1, time: 1000,
                            anim: 2
                        });
                    } else {
                        layer.msg(data.message, {
                            icon: 5, time: 1000,
                            anim: 2
                        });
                    }
                },
                error: function () {
                    layer.msg('标签删除失败!', {
                        icon: 5, time: 1000,
                        anim: 2
                    });
                }
            });
        });
    }

    function update(id) {
        location.href = "/admin/cate/detail?cateId=" + id + "&cateType=updateCate";
    }
</script>
</body>
</html>